<!-- 优惠券详情  -->
<template>
  <s-layout title="会员详情" :bgStyle="{ color: '#f2f2f2' }">
    <view class="bg-white">
      <!-- 详情卡片 -->
      <view class="detail-wrap ss-p-20">
        <view class="detail-box">
          <view class="tag-box ss-flex ss-col-center ss-row-center">
            <image
              class="tag-image"
              :src="sheep.$url.static(state.data.image)"
              mode="aspectFit"
            ></image>
          </view>
          <view class="top ss-flex-col ss-col-center">
            <view class="title ss-m-t-50 ss-m-b-20 ss-m-x-20">{{state.data.level_name}}</view>
            <view class="coupon-line ss-m-t-14"></view>
          </view>
          <view class="bottom">
           <view class="content ss-p-b-20">
           	  <rich-text :nodes="state.data.content"></rich-text> 
           </view>
          </view>
		  
		
        </view>
      </view>
	    
     <detail-tabbar>
		   <block>
       <view class="buy-box ss-flex ss-col-center ss-p-r-20" >
		
         <button
           class="ss-reset-button buy-btn ui-Shadow-Main" @click="onSubmit()">
           立即购买
         </button>
       </view>
	   	 </block>
     </detail-tabbar>

    </view>
  </s-layout>
</template>

<script setup>
  import sheep from '@/sheep';
  import { onLoad, onReachBottom } from '@dcloudio/uni-app';
  import { reactive } from 'vue';
  import _ from 'lodash';


  const state = reactive({
    id: 0,
    loadStatus: '',
	data:{}
  });

  async function onSubmit() {
    const { code ,data} = await sheep.$api.trade.purchase(
  	{vid:state.id}
    );
    if (code === 1) {
  	  sheep.$router.reLaunch('/pages/pay/index', {
  	    orderSN: data.order_sn,
  	    type: 'purchase',
  	  });
    }
  }
  async function getContent(id) {
	  let res = await sheep.$api.trade.userLevelDetail({
	  	levelid:id
	  });
	  state.data =res.data
  }
  onLoad((options) => {
    state.id = options.id;
    getContent(state.id);
  });
</script>

<style lang="scss" scoped>
	// 购买
	.buy-box {
	  .add-btn {
	    width: 100%;
	    height: 72rpx;
	    font-weight: 500;
	    font-size: 28rpx;
	    border-radius: 40rpx 40rpx 40rpx 40rpx;
	    background-color: var(--ui-BG-Main-light);
	    color: var(--ui-BG-Main);
	  }
	
	  .buy-btn {
	     width: 100%;
	    height: 72rpx;
	    font-weight: 500;
	    font-size: 28rpx;
	
	       border-radius: 40rpx 40rpx 40rpx 40rpx;
	    background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
	    color: $white;
		 position: fixed;
		  bottom: 50rpx;
		     left: 0;
		     right: 0;
	  }
	
	  .disabled-btn {
	    width: 428rpx;
	    height: 72rpx;
	    font-weight: 500;
	    font-size: 28rpx;
	
	    border-radius: 0 40rpx 40rpx 0;
	    background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
	    color: $white;
	  }
	}
	
  .goods-title {
    font-size: 34rpx;
    font-weight: bold;
    color: #333333;
  }

  .detail-wrap {
    background: linear-gradient(
      180deg,
      var(--ui-BG-Main),
      var(--ui-BG-Main-gradient),
      var(--ui-BG-Main),
      #fff
    );
  }

  .detail-box {
    // background-color: var(--ui-BG);
    border-radius: 6rpx;
    position: relative;
    margin-top: 100rpx;
    .tag-box {
      width: 140rpx;
      height: 140rpx;
      background: var(--ui-BG);
      border-radius: 50%;
      position: absolute;
      top: -70rpx;
      left: 50%;
      z-index: 6;
      transform: translateX(-50%);

      .tag-image {
        width: 104rpx;
        height: 104rpx;
        border-radius: 50%;
      }
    }

    .top {
      background-color: #fff;
      border-radius: 20rpx 20rpx 0 0;
      -webkit-mask: radial-gradient(circle at 16rpx 100%, #0000 16rpx, red 0) -16rpx;
      padding: 110rpx 0 0 0;
      position: relative;
      z-index: 5;

      .title {
        font-size: 40rpx;
        color: #333;
        font-weight: bold;
      }

      .subtitle {
        font-size: 28rpx;
        color: #333333;
      }

      .use-btn {
        width: 386rpx;
        height: 80rpx;
        line-height: 80rpx;
        background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
        border-radius: 40rpx;
        color: $white;
      }

      .disable-btn {
        width: 386rpx;
        height: 80rpx;
        line-height: 80rpx;
        background: #e5e5e5;
        border-radius: 40rpx;
        color: $white;
      }

      .time {
        font-size: 26rpx;
        font-weight: 400;
        color: #999999;
      }

      .coupon-line {
        width: 95%;
        border-bottom: 2rpx solid #eeeeee;
      }
    }

    .bottom {
      background-color: #fff;
      border-radius: 0 0 20rpx 20rpx;
      -webkit-mask: radial-gradient(circle at 16rpx 0%, #0000 16rpx, red 0) -16rpx;
      padding: 40rpx 30rpx;

      .type {
        height: 96rpx;
        border-bottom: 2rpx solid #eeeeee;
      }
    }

    .des {
      font-size: 24rpx;
      font-weight: 400;
      color: #666666;
    }
  }

  .all-user {
    width: 100%;
    height: 300rpx;
    font-size: 34rpx;
    font-weight: bold;
    color: #333333;
  }
</style>
